package pl.agh.pp.zephyr.algorithms;

import java.util.HashMap;
import java.util.Map;

/**
 * Modeluje pewne zadanie do wykonania w strukturze sieci, np: utworzenie
 * pokoju, połączenie pokoji, podłączenie użytkownika do pokoju.
 * */
public class Command {

	/*
	 * public static final int ROUTE_SIMPLE_SOURCE_USER_HASH = 0x0001; public
	 * static final int ROUTE_SIMPLE_DESTINATION_ROOM_HASH = 0x0002;
	 * 
	 * public static final int CREATE_ROOM_MCU_HASH = 0x0004; public static
	 * final int CREATE_ROOM_ROOM_ALIAS = 0x0010;
	 * 
	 * public static final int MIGRATE_USER_USER_HASH = 0x0020; public static
	 * final int MIGRATE_USER_FROM_ROOM_HASH = 0x0040; public static final int
	 * MIGRATE_USER_TO_ROOM_HASH = 0x0100;
	 * 
	 * public static final int LINK_ROOMS_ROOM_FROM_HASH = 0x0200; public static
	 * final int LINK_ROOMS_ROOM_TO_HASH = 0x0400;
	 */

	/**
	 * Typy argumentów
	 * */
	public enum ArgKey {
		ROUTE_SIMPLE_SOURCE_USER_HASH,
		ROUTE_SIMPLE_DESTINATION_ROOM_HASH, 
		CREATE_ROOM_MCU_HASH,
		CREATE_ROOM_ROOM_ALIAS,
		MIGRATE_USER_USER_HASH,
		MIGRATE_USER_FROM_ROOM_HASH,
		MIGRATE_USER_TO_ROOM_HASH,
		LINK_ROOMS_ROOM_FROM_HASH,
		ROUTE_SIMPLE_ALIAS,
		ROUTE_SIMPLE_CALLING_ENDPOINT_ID,
		ROUTE_SIMPLE_CALL_REF,
		CONNECT_ROOM_TO_MCU_MCU_HASH,
		CONNECT_ROOM_TO_MCU_ROOM_HASH,
		ROUTE_TO_GATEWAY_ALIAS,
		ROUTE_TO_GATEWAY_IP,
		ROUTE_TO_GATEWAY_PORT,
		ROUTE_TO_GATEWAY_CALLING_EP_ID,
		ROUTE_TO_GATEWAY_CALL_REF,
		ROUTE_REJECT_CALLING_EP_ID,
		ROUTE_REJECT_CALL_REF,
		CONNECT_ROOMS_MCU_FROM_HASH,
		CONNECT_ROOMS_MCU_TO_HASH,
		CONNECT_ROOMS_ROOM_HASH
	}

	// mapa przechowuje wartości pewnych argumentów
	// np. nazwy hashe pokojów do połączenia
	public final Map<ArgKey, Object> params = new HashMap<ArgKey, Object>();

	public enum TYPE {
		ROUTE_SIMPLE, ROUTE_TO_GATEWAY, CREATE_ROOM, LINK_ROOMS, MIGRATE_USER, ROUTE_REJECT, CONNECT_ROOM_TO_MCU, CONNECT_ROOMS
	}

	public Command(TYPE type) {
		super();
		this.type = type;
	}

	public final TYPE type;

	public TYPE getType() {
		return type;
	}

	@Override
	public String toString() {
		String s = "Command [type=" + type + "] { ";
		for (ArgKey i : params.keySet()) {
			s += i.toString() + "=" + params.get(i) + ", ";
		}
		return s.substring(0, s.length() - 1) + "}";
	}

}
